package it.fuesi.signit.activities;

import it.fuesi.signit.CurrentSettings;
import it.fuesi.signit.R;
import it.fuesi.signit.fragments.SettingsDetailFragment;
import it.fuesi.signit.fragments.SettingsListFragment;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.FrameLayout;


public class SettingsActivity extends FragmentActivity {

	private static final String TAG = "SignPicturesSettings";
	
	private FrameLayout mFrameList;
	private FrameLayout mFrameDetail;
	
	private CurrentSettings settings;
		
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.settings);
		
		mFrameList = (FrameLayout)findViewById(R.id.signatures_list);
		mFrameDetail = (FrameLayout)findViewById(R.id.signature_detail);

		refreshSignaruesList();
		
		refreshSignatureDetail();
	}

	public void refreshSignaruesList(){
		FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction();
		transaction1.replace(R.id.signatures_list, new SettingsListFragment());
		transaction1.commit();

	}
	

	public void refreshSignatureDetail(){
		FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
		transaction2.replace(R.id.signature_detail, new SettingsDetailFragment());
		transaction2.commit();
	
	}
	

	/**
	 * Set up the {@link android.app.ActionBar}, if the API is available.
	 */
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private void setupActionBar() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			// Show the Up button in the action bar.
			getActionBar().setDisplayHomeAsUpEnabled(true);
		}
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			finish();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.settings, menu);
		return true;
	}
	
	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		switch(item.getItemId()){
			case android.R.id.home:{
				finish();
			}
			break;
		}
		return true;
	}
	
}
